const http = require("http")
const fs = require("fs")

var obj = {
    name: "小刚"
}

const server = http.createServer((req, res)=> {
    console.log(req.url)
    res.setHeader("Content-Type", "application/json;charset=utf-8")
    if(req.url === "/a.json") {
        // fs.readFile("./a.json","utf-8", (err, data)=> {
        //     res.end(data)
        // })
        res.end(JSON.stringify(obj))
    }
})

server.listen(5000, ()=> {
    console.log("服务器监听成功")
})